package com.golang.api.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.golang.api.domain.*;
import com.golang.api.mapper.*;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class OrderRepository {

    @Resource
    OrderInfoMapper orderInfoMapper;

    @Resource
    OrderItemMapper OrderItemMapper;

    @Resource
    OrderPicMapper orderPicMapper;




    public boolean saveOrderInfo(OrderInfo orderInfo) {
        return orderInfoMapper.insertOrUpdate(orderInfo);
    }


    public int insertOrderPic(OrderPic entity) {
        return orderPicMapper.insert(entity);
    }

    public int insertOrderItem(OrderItem entity) {
        return OrderItemMapper.insert(entity);
    }



    public OrderInfo queryOrderInfoByOrderId(String orderId) {

        LambdaQueryWrapper<OrderInfo> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(OrderInfo::getOrderId, orderId);

        return orderInfoMapper.selectOne(queryWrapper);
    }

}
